/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package solitaireofdoom.klondike;

import java.awt.*;
import java.awt.image.*;

import solitaireofdoom.solitaire.*;

/**
 * The KlondikeDrawPile and KlondikeDonePile both inherit the Pile class and serve basic pile functions.
 *
 * @author Administrator
 */
public class KlondikeDonePile extends Pile
{
    private Klondike klondike;

    public KlondikeDonePile(Klondike klondike, BufferedImage cards)
    {
        super();

        this.cards = cards;
        this.klondike = klondike;
    }

    public KlondikeDonePile(Deck deck, Klondike klondike, BufferedImage cards)
    {
        super();

        this.cards = cards;
        this.klondike = klondike;

        for (int i = 0; i < deck.size(); i++)
        {
            CardCanvas cc = new CardCanvas(deck.getCard(i), cards);
            this.add(cc);
        }
    }

    /**
     * Adds a <b>CardCanvas</b> to this pile.
     * @param cc the <b>CardCanvas</b> that is supposed to be added to this pile.
     * @return returns the new <b>CardCanvas</b>
     */
    public java.awt.Component add(CardCanvas cc)
    {
        cc.pile = this;
        this.pileCards.add(cc);

        this.redraw();

        return cc;
    }

    /**
     * Shows the cards in the pile
     */
    public void redraw()
    {
        this.removeAll();

        if (this.pileCards.size() > 0)
        {
            this.pileCards.lastElement().setLocation(1, 1);
            this.add((Component)this.pileCards.lastElement());
        }

        this.klondike.pileChanged(false);
    }

    /**
     * Moves cards to the suit piles(foundations) where applicable
     */
    public void autoMoveToSuit()
    {
        this.klondike.autoMoveToSuit();
    }
}
